package com.naizhuai.ui.msgmanager.multtype;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.naizhuai.R;
import com.naizhuai.receiver.PushCommonJump;
import com.naizhuai.ui.entity.JumpBean;
import com.naizhuai.ui.entity.User.AppMessageList;

import butterknife.BindView;
import butterknife.ButterKnife;
import me.drakeet.multitype.ItemViewBinder;

/**
 * @author：lichenxi
 * @date 2018/6/23 16
 * email：525603977@qq.com
 * Fighting
 */
public class MainFlowViewBinder extends ItemViewBinder<AppMessageList, MainFlowViewBinder.ViewHolder> {
    @NonNull
    @Override
    protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View root = inflater.inflate(R.layout.item_main_flow, parent, false);
        return new ViewHolder(root);
    }

    @Override
    protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull AppMessageList mainFlow) {
        holder.title.setText(mainFlow.title);
        Context context=holder.itemView.getContext();
        if ("1".equals(mainFlow.isRead)){
          holder.redMsg.setVisibility(View.VISIBLE);
        }else {
            holder.redMsg.setVisibility(View.GONE);
        }
       holder.itemView.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               PushCommonJump.notifyJump(context,mainFlow.mJumpBean);
           }
       });
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.title)
        TextView title;
        @BindView(R.id.red_msg)
        View redMsg;
        ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
